package cn.edu.nyist.service.Impl;

import cn.edu.nyist.entity.UserSellInfo;
import cn.edu.nyist.mapper.UserSellInfoMapper;
import cn.edu.nyist.service.UserSellInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (UserSellInfo)表服务实现类
 *
 * @author makejava
 * @since 2021-04-10 00:50:25
 */
@Service("userSellInfoService")
public class UserSellInfoServiceImpl implements UserSellInfoService {
    @Resource
    private UserSellInfoMapper userSellInfoMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public UserSellInfo queryById(Integer id) {
        return this.userSellInfoMapper.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<UserSellInfo> queryAllByLimit(int offset, int limit) {
        return this.userSellInfoMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param userSellInfo 实例对象
     * @return 实例对象
     */
    @Override
    public Integer insert(UserSellInfo userSellInfo) {
        return userSellInfoMapper.insert(userSellInfo);
    }

    /**
     * 修改数据
     *
     * @param userSellInfo 实例对象
     * @return 实例对象
     */
    @Override
    public UserSellInfo update(UserSellInfo userSellInfo) {
        this.userSellInfoMapper.update(userSellInfo);
        return this.queryById(userSellInfo.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.userSellInfoMapper.deleteById(id) > 0;
    }

    @Override
    public int deleteByUserId(Map<String, Object> paramMap) {
        return userSellInfoMapper.deleteByUserId(paramMap);
    }
}